<#assign f=JspTaglibs["http://www.casic304.cn/f"] />
<div>
    <table id="wQbdQuasuporgBaseTable" lay-filter="wQbdQuasuporgBaseTable"></table>
    <form class="reportList-isShow">
        <input type="hidden" id="successDataId" name="successDataId">
    </form>
</div>
<!-- 右侧工具栏 -->
<script type="text/html" id="wQbdQuasuporgBaseRightToolsBar">
    <a class="RightBtn" lay-event="particulars">详情</a>
</script>

<script>
    //一般直接写在一个js文件中
    layui.use(['index','table','publicMethods','jquery','layer'], function () {
        var table = layui.table;
        var publicMethods = layui.publicMethods;
        var $ = layui.jquery;
        var layer = layui.layer;
        var tableH=publicMethods.layerHeight();
        var dataId = "${dataId}";

        var cols = [ //表头
            {type: 'checkbox', fixed: 'left'}
            ,{field: 'sn', type: 'numbers', title: '序号', fixed: 'left'}
            ,{field: 'orgName', title: '机构名称',minWidth:120}
            ,{field: 'affiliatedUnits', title: '挂靠单位',minWidth:120}
            ,{field: 'replyNo', title: '批复文号',minWidth:100}
            ,{field: 'contacts', title: '联系人',minWidth:100}
            ,{field: 'contactsInfo', title: '联系方式',minWidth:100}
            ,{field: 'replyTime', title: '批复时间',minWidth:110,templet: function (d) {
                    return publicMethods.timeData(d.replyTime,"1 ");
                }}
            ,{
                fixed: 'right',
                title: '管理',
                width:80,
                align:'center',
                toolbar: '#wQbdQuasuporgBaseRightToolsBar'
            }
        ];

        //第一个实例
        table.render({
            elem: '#wQbdQuasuporgBaseTable'
            ,height:tableH
            ,url: serverPath.qbdmsPath + '/qbdms/wQbdQuasuporgBase/reportList?id=' + dataId + "&tableName=W_QBD_QUASUPORG_BASE"
            ,page: false //开启分页
            ,method: 'post'
            ,autoSort: false //是否排序
            ,cols: [cols],done:function () {
            }
        });

        table.on('tool(wQbdQuasuporgBaseTable)', function(obj) {
            var data = obj.data, //获得当前行数据
                    layEvent = obj.event; //获得 lay-event 对应的值
            switch(layEvent){
                case "particulars":
                    var height=publicMethods.layHeight('body');
                    layer.open({
                        type: 2,
                        area: ['96%', height],
                        title: ['质量技术支撑机构详情'],
                        content: serverPath.qbdmsPath + '/qbdms/wQbdQuasuporgBase/view/particulars?id=' + data.id + "&isClose=true"
                    });
                    break;
            }
        });

        table.on('checkbox(wQbdQuasuporgBaseTable)', function (obj) {
            if (obj.type == "all") {
                if (obj.checked) {
                    $("input[name='successDataId']").val("");
                    var checkStatus = table.checkStatus('wQbdQuasuporgBaseTable');
                    var valArr = checkStatus.data;//选中行数据
                    var ceshiVal = $("input[name='successDataId']").val();
                    for (var i = 0; i < valArr.length; i++) {
                        ceshiVal = ceshiVal + valArr[i].id + ",";
                    }
                    $("input[name='successDataId']").val(ceshiVal);
                } else {
                    $("input[name='successDataId']").val("");
                }
            } else {
                if (obj.checked) {
                    var ceshiVal = $("input[name='successDataId']").val();
                    $("input[name='successDataId']").val(ceshiVal + obj.data.id + ",");
                } else {
                    var ceshiVal = $("input[name='successDataId']").val();
                    var newVal = "";
                    var valArr = ceshiVal.split(obj.data.id + ",");
                    for (var i = 0; i < valArr.length; i++) {
                        newVal += valArr[i];
                    }
                    $("input[name='successDataId']").val(newVal);
                }
            }
        });

    });
</script>